<template>
  <div>
    <Table :data="purchaseData" :columns="columns"></Table>
    <Page
        style="margin-top: 10px"
        :total="total"
        :current="curPage"
        :page-size="pageSize"
        :show-elevator="true"
        @on-change="changePage"
    ></Page>
  </div>
</template>

<script>
import Api from '@/api/purchase'
const columns = [
  { title: 'ID', key: 'wid' },
  { title: '申请订单编号', key: 'inputFormNum' },
  { title: '商品名称', key: 'name' },
  { title: '商品数量', key: 'number' }
]
columns.forEach(item => {
  item.align = 'center'
})

export default {
  name: "list",
  data () {
    return {
      purchaseData: [],
      columns: columns,
      pageSize: 20,
      curPage: 1,
      total: 0
    }
  },
  mounted () {
    this.list()
  },
  methods: {
    list () {
      Api.list({
        pageSize: this.pageSize,
        curPage: this.curPage
      }).then(res => {
        const data = res.data
        if (data.resultCode !== 200) {
          this.$Message.error(data.message)
        }
        this.total = data.data.total
        this.purchaseData = data.data.result
      })
    },
    changePage (i) {
      this.curPage = i
      this.list()
    }
  }
}
</script>

<style scoped>

</style>
